package com.guit.hrms.mapper;

import com.guit.hrms.po.Setting;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface SettingsMapper {
    /**
     * 获取系统设置
     * @return 设置列表
     */
    @Select("select * from settings")
    List<Setting> getSettings();

    /**
     * 更新系统设置
     * @param setting 设置项信息
     * @return 更新结果
     */
    @Update("UPDATE settings SET setting_value = #{settingValue} WHERE setting_id = #{settingId}")
    int updateSetting(@Param("settingId") Integer settingId, 
                     @Param("settingValue") String settingValue);

    /**
     * 通过设置名获取设置的值
     * @param setting_name
     * @return
     */
    @Select("select  setting_value  from settings where setting_name = #{setting_name}")
    Integer getValueBySettingName(String setting_name);
}
